package com.tiennt.android.callnotes.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DbHandler extends SQLiteOpenHelper {

	public static final String TAG = "DbHandler";

	public DbHandler(Context context) {
		super(context, DbUtils.DB_NAME, null, DbUtils.DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DbUtils.QUERY_CREATE_TABLE_CONTENT);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.i(TAG, "Upgrading database from version " + oldVersion + " to "
				+ newVersion + ".");
		db.execSQL("drop table if exists " + DbUtils.TB_NOTESDATA_NAME);
		onCreate(db);
	}
}
